#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define M 101

/*
3 7
1 2 1 5 4 4 1
*/

struct node_t {
	node_t *prev, *next; 
	int val; 
}; 

node_t lru_head; 
int m, n; 
int nr_lru=0; 
int nr_seek=0; 

void insert(node_t *p, node_t *prev, node_t *next)
{
	p->prev = prev; 
	p->next = next; 
	prev->next = p; 
	next->prev = p; 
}

void remove(node_t *p)
{
	p->next->prev = p->prev; 
	p->prev->next = p->next; 
	p->next = p; 
	p->prev = p; 
}

void dump_lru(void)
{
	node_t *p=&lru_head; 
	
	printf("val=%d self=%p, prev=%p, next=%p\n", p->val, p, p->prev, p->next); 
	for (p=lru_head.next; p!=&lru_head; p=p->next) {
		printf("val=%d self=%p, prev=%p, next=%p\n", p->val, p, p->prev, p->next); 
	}	
}

void seek_dict(int v)
{
	//printf("seek %d, nr_lru=%d, nr_seek=%d\n", v, nr_lru, nr_seek); 
	
	node_t *p; 
	if (nr_lru>=m) {
		p = lru_head.prev; 
		remove(p); 
		nr_lru--; 
	} else {
		p = (node_t *)malloc(sizeof(node_t)); 
	}
	p->val = v; 
	insert(p, &lru_head, lru_head.next); 
	nr_lru++; 
	nr_seek++; 
}

void lookup(int v)
{
	node_t *p=lru_head.next; 
	
	//printf("look %d, nr_lru=%d, nr_seek=%d\n", v, nr_lru, nr_seek); 
	for (p=lru_head.next; p!=&lru_head; p=p->next) {
		if (p->val!=v) 
			continue; 

		/* remove p from list */
		//remove(p); 
		//insert(p, &lru_head, lru_head.next); 
		return; 
	}
	seek_dict(v); 
}

int main()
{
	int i, a; 
	lru_head.prev = &lru_head; 
	lru_head.next = &lru_head; 
	lru_head.val = -1; 
	freopen("p1540_1.in", "r", stdin); 
	scanf("%d %d", &m, &n); 
	for (i=0; i<n; i++) {
		scanf("%d", &a); 
		lookup(a); 
	}
	printf("%d\n", nr_seek); 
	return 0; 
}


